<?php


namespace app\admin\controller;


use app\common\controller\BaseController;
use app\common\model\Admin as adminModel;
use thans\jwt\facade\JWTAuth;
use think\facade\Request;
use think\facade\View;
//这个类用来登录的
class User extends BaseController {


    public function initialize(){
        parent::initialize();
        View::engine()->layout(false);
    }

    public function userLoginLogList(){
        $adminModel = new adminModel();
        return $adminModel->userLoginLogList();
    }

    public function Login(){
        try {
            $auth_info = JWTAuth::auth();
            return redirect(url('/'))->send();
        }catch (\Exception $e){
            View::assign('shop_name','飞行猫');
            if($this->request->isPost()){

                $adminModel = new adminModel();
                return $adminModel->toLogin($this->request->post());

//                if (!captcha_check($this->request->param('yzm',''))) {
//                    return json(error_code(10012));
//                }else{
//                    $adminModel = new adminModel();
//                    return $adminModel->toLogin($this->request->post());
//                }

            }else{
                return View::fetch();

            }
        }
    }


    public function logout(){
        JWTAuth::refresh();
        View::assign('msg','退出成功');
        View::assign('url','/admin.html');
        return View::fetch('common/tpl_success');
    }

}